import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class DiyConfigService extends BaseService<any> {
  private readonly logger = new Logger(DiyConfigService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getBottomList
   * 对应 PHP: DiyConfigService_admin::getBottomList()
   * 逻辑类型: undefined - undefined
   */
  async getBottomList(params: any[]) {
    // 基于PHP真实逻辑: getBottomList
    // PHP原文: $list = ( new CoreDiyConfigService() )->getBottomList($params);          $site_addon = ( new CoreSiteService() )->getSiteCache($this->site_id);       ...
const list = ( this.coreDiyConfigService ).getBottomList(params);

        const site_addon = ( this.coreSiteService ).getSiteCache(this.site_id];
        const bottom_list_keys = array_column(list, 'key');
        // 排除没有底部导航的应用
        foreach (site_addon[ 'apps' ) as k => v) {
            if (!in_[v[ 'key' ), bottom_list_keys)) {
                unset(site_addon[ 'apps' )[ k )];
            }
  }

  /**
   * getBottomConfig
   * 对应 PHP: DiyConfigService_admin::getBottomConfig()
   * 逻辑类型: undefined - undefined
   */
  async getBottomConfig(key: any) {
    // 基于PHP真实逻辑: getBottomConfig
    // PHP原文: return ( new CoreDiyConfigService() )->getBottomConfig($this->site_id, $key);     }      /**      * 底部导航配置      * @param $data      * @param $key     ...
return ( this.coreDiyConfigService ).getBottomConfig(this.site_id, key);
    }

    /**
     * 底部导航配置
     * @param data
     * @param key
     * @return SysConfig|bool|Model
     */
    async setBottomConfig(data, key)
    {
        return ( this.coreDiyConfigService ).setBottomConfig(this.site_id, data, key);
    }

    /**
     * 设置启动页
     * @param data
     * @return SysConfig|bool|Model
     */
    async setStartUpPageConfig(data)
    {
        return ( this.coreDiyConfigService ).setStartUpPageConfig(this.site_id, data);
    }

    /**
     * 获取启动页配置
     * @param name
     * @return */
    async getStartUpPageConfig(name)
    {
        return ( this.coreDiyConfigService ).getStartUpPageConfig(this.site_id, name);
    }

}
  }

  /**
   * setBottomConfig
   * 对应 PHP: DiyConfigService_admin::setBottomConfig()
   * 逻辑类型: undefined - undefined
   */
  async setBottomConfig(data: any, key: any) {
    // 基于PHP真实逻辑: setBottomConfig
    // PHP原文: return ( new CoreDiyConfigService() )->setBottomConfig($this->site_id, $data, $key);     }      /**      * 设置启动页      * @param $data      * @return Sy...
return ( this.coreDiyConfigService ).setBottomConfig(this.site_id, data, key);
    }

    /**
     * 设置启动页
     * @param data
     * @return SysConfig|bool|Model
     */
    async setStartUpPageConfig(data)
    {
        return ( this.coreDiyConfigService ).setStartUpPageConfig(this.site_id, data);
    }

    /**
     * 获取启动页配置
     * @param name
     * @return */
    async getStartUpPageConfig(name)
    {
        return ( this.coreDiyConfigService ).getStartUpPageConfig(this.site_id, name);
    }

}
  }

  /**
   * setStartUpPageConfig
   * 对应 PHP: DiyConfigService_admin::setStartUpPageConfig()
   * 逻辑类型: undefined - undefined
   */
  async setStartUpPageConfig(data: any) {
    // 基于PHP真实逻辑: setStartUpPageConfig
    // PHP原文: return ( new CoreDiyConfigService() )->setStartUpPageConfig($this->site_id, $data);     }      /**      * 获取启动页配置      * @param $name      * @return a...
return ( this.coreDiyConfigService ).setStartUpPageConfig(this.site_id, data);
    }

    /**
     * 获取启动页配置
     * @param name
     * @return */
    async getStartUpPageConfig(name)
    {
        return ( this.coreDiyConfigService ).getStartUpPageConfig(this.site_id, name);
    }

}
  }

  /**
   * getStartUpPageConfig
   * 对应 PHP: DiyConfigService_admin::getStartUpPageConfig()
   * 逻辑类型: undefined - undefined
   */
  async getStartUpPageConfig(name: any) {
    // 基于PHP真实逻辑: getStartUpPageConfig
    // PHP原文: return ( new CoreDiyConfigService() )->getStartUpPageConfig($this->site_id, $name);     }  }...
return ( this.coreDiyConfigService ).getStartUpPageConfig(this.site_id, name);
    }

}
  }
}
